home *** CD-ROM | disk | FTP | other *** search
- Path: oxy.rust.net!usenet
- From: ebennett@rust.net
- Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.apps.compatibility.win95,comp.lang.c++
- Subject: Re: HELP !!! Memory - Allocation
- Date: Thu, 25 Jan 1996 04:01:25 GMT
- Organization: Rust Net - High Speed Internet in Detroit 810-642-2276
- Message-ID: <4e6kof$ela@oxy.rust.net>
- References: <NEWTNews.751.822443462.Postmaster@Jerusalem.netvision.net.il>
- NNTP-Posting-Host: liv-18.rust.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- iti@Jerusalem.netvision.net.il wrote:
-
- >I am using Visual C++ to write a Windows Application - and I am having
- >a memory problem. I want to dynamically allocate "nTemp" bytes of memory
- >to read in a char string, or the most memory available up to "nTemp"
- >bytes.
-
- >My questions being:
- > 1. How can I most efficiantly do this?
- > 2. Should I use
- > -> pChar = (char*) malloc(nTemp); Or
- > -> pChar = new char[nTemp];
-
- Personal Opinion: If you are using C++, use C++. (i.e., go with new
- instead of malloc). The only technical reason for this is to make
- sure object constructors are called when allocating an array of
- objects. In this case it really does not matter, but I would avoid
- using malloc in C++ code.
-
- Earl Bennett
-
-